package com.fc.mall.portal.controller;

import com.fc.mall.base.object.Result;
import com.fc.mall.model.UmsMemberAccount;
import com.fc.mall.model.UmsMemberAccountChangeHistory;
import com.fc.mall.portal.service.UmsMemberAccountChangeHistoryService;
import com.fc.mall.portal.service.UmsMemberAccountService;
import com.fc.mall.util.Constants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/member/account")
@Api(tags = "UmsMemberAccountController", description = "会员账户信息")
public class UmsMemberAccountController {
    @Autowired
    private UmsMemberAccountService memberAccountService;
    @Autowired
    private UmsMemberAccountChangeHistoryService memberAccountChangeHistoryService;

    @ApiOperation("会员账户信息")
    @GetMapping(value = "/info")
    public Result info() {
        UmsMemberAccount memberAccount = memberAccountService.getMemberAccountInfo();
        return Result.success(memberAccount);
    }

    @ApiOperation("会员账户历史记录")
    @ApiImplicitParam(name = "accountType", value = "账户类型 1-> 会员账号 2-> 会员待发放金账户",
            allowableValues = "1,2", paramType = "query", dataType = "integer")
    @GetMapping(value = "/change/history")
    public Result queryAccountHistoryList(@RequestParam(value = "accountType", required = false) Integer accountType) {
        if(accountType == null)
        {
            accountType = Constants.AccountType.MemberAccount.getValue();
        }
        List<UmsMemberAccountChangeHistory> memberAccountChangeHistoryList = memberAccountChangeHistoryService.queryAccountChangeHistoryList(accountType);
        return Result.success(memberAccountChangeHistoryList);
    }

}
